<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * Ajax Delete File
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 10.10.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * class ajaxDeleteDatablock
    ****
    * @package ajax
    * @author tb@essentialmind.com
    * @version n/a
    * @since 10.05.2011
    * @copyright essentialmind.com 2005
    ***/
    class ajaxDeleteEstateImage extends ajaxAction{

        public function process(){
            
            $id = (int)$_REQUEST['image'];
            $isGroundplan = (int)$_REQUEST['isGroundplan'];
            
            if($id > 0) {

                // remove groundplan from the estate_node
                if ($isGroundplan) {
                    $this->db->Execute("UPDATE node_estate SET groundplan_id = NULL WHERE groundplan_id = " . $id);
                }
            
                //update database
                $this->db->Execute("DELETE FROM estate_pictures WHERE id = ".$id);
                
                $this->r->status = true;
            } else {
                $this->r->status = false;
            }

        }
    }
?>